package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.entity.AddressBook;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressBookMapper {

    @Select("select * from address_book where user_id = #{userId}")
    List<AddressBook> getAddressBookListByUserId(Long userId);

    /**
     * 新增地址
     * @param addressBook
     */
    void insertAddress(AddressBook addressBook);

    @Select("select * from address_book where id = #{id};")
    AddressBook getAddresById(Integer id);

    /**
     * 更新address
     * @param addressBook
     */
    void updateAddress (AddressBook addressBook);


    List<AddressBook> getAddress(AddressBook addressBook);

    @Select("select * from address_book where user_id = #{currentId} and is_default = 1;")
    AddressBook getUserDefaultAddress(Long currentId);

    @Delete("delete from address_book where id = #{id}")
    void deleteAddressById(Long id);
}